<template>
  <el-dialog
    title="修改默认价格"
    :visible="show"
    width="30%"
    @close="close"
  >
    <div class="rowFlex allCenter">
      <p style="margin-right:10px;">每日签到获得</p> <el-input v-model="free_coin" clearable style="width:160px;" placeholder="请输入数量" /> <p style="margin-left:10px;">赠币</p>
    </div>
    <span slot="footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { setConfig } from '@/api/recharge'
export default {
  props: ['show', 'info'],
  data() {
    return {
      free_coin: ''
    }
  },
  watch: {
    show(newVal, oldVal) {
      if (newVal) {
        this.free_coin = this.info.free_coin
      }
    }
  },
  methods: {
    close() {
      this.$emit('update:show', false)
    },
    submit() {
      if (this.free_coin > 0) {
        const data = {
          free_coin: this.free_coin,
          mini_app_id: ''
        }
        this.close()
        setConfig(data).then(res => {
          if (res.status_code === 1) {
            this.$emit('ok')
          }
        })
      }
    }
  }
}
</script>

<style>

</style>